import {
	SANBAOWULIAN_BASE_URL,
} from '@/config/app';
import {
	toLogin
} from '@/libs/login.js';

const request = (params) => {
	return new Promise((resolve, reject) => {
		let url = SANBAOWULIAN_BASE_URL + params.API_URL;
		return uni.request({
			url: url,
			data: Object.assign({}, params.data) || {},
			method: 'POST',
			header: {
				'Content-Type': 'application/x-www-form-urlencoded'
			},
			success: (res) => {
				if (res.data.status == -2) {
					toLogin();
				}
				resolve(res.data);
			},
			fail: (err) => {
				reject(err);
			}
		})
	})
}

export default request;